package com.bc.bczbweb.controller;

import com.bc.bcapi.dao.T_Order_kycMapper;
import com.bc.bccore.util.PageHelper;
import com.bc.bccore.zbconfig.ZbConfig;
import com.bc.bcmodel.domain.T_Order_kycModel;
import com.bc.bcmodel.req.MngOrderListReq;
import com.bc.bcmodel.resp.MngOrderListResp;
import com.bc.commoncore.util.StringUtils;
import com.bc.commonentity.common.JsonResult;
import com.bc.bcapi.service.T_OrderService;
import com.bc.bcmodel.domain.T_OrderModel;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.math.BigInteger;

import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("t_order")
public class T_OrderController extends BaseController {
    @Autowired
    T_OrderService t_OrderService;

    @Autowired
    T_Order_kycMapper t_order_kycMapper;

    @RequestMapping("list")
    public ModelAndView list() {
        ModelAndView view = super.baseView("列表", "t_order/list");
        return view;
    }

    @RequestMapping(value = "listdo", method = RequestMethod.POST)
    public ModelAndView listdo(MngOrderListReq req) {
        ModelAndView view = super.baseViewAjax("列表", "t_order/listdo");
        PageInfo<MngOrderListResp> pageInfo = t_OrderService.getList(req);
        view.addObject("data", pageInfo.getList());
        view.addObject("page", PageHelper.GetAjaxHtml(pageInfo, "javascript:loadpage(##);"));
        return view;
    }

    @RequestMapping("add")
    public ModelAndView add(String oid) {
        String title = "详情";
        ModelAndView view = super.baseView(title, "t_order/add");
        T_OrderModel model = new T_OrderModel();
        model.setOid(oid);
        T_OrderModel data = t_OrderService.findByNamedParam(model);

        T_Order_kycModel t_order_kycModel = new T_Order_kycModel();
        t_order_kycModel.setOid(oid);
        T_Order_kycModel resultOrderKycModel = t_order_kycMapper.findByNamedParam(t_order_kycModel);
        view.addObject("order_kyc", resultOrderKycModel);
        view.addObject("data", data);
        view.addObject("title", title);
        view.addObject("imgurl", ZbConfig.getImgUrl());
        return view;
    }
}